<template>
    <div class="homeContainer">
        <!-- 轮播图 -->
        <div class="carousel">
            <carouse :carouselList="carouselList" :isFull="true"></carouse>
        </div>

        <!-- 九宫格 2 六宫格 -->
        <div class="gridView">
            <ul class="mui-table-view mui-grid-view mui-grid-9">
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/home/newsList">
                        <img src="../../images/menu1.png">
                        <div class="mui-media-body">新闻资讯</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/home/photoList">
                        <img src="../../images/menu2.png">
                        <div class="mui-media-body">图片分享</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/home/goodsList">
                        <img src="../../images/menu3.png">
                        <div class="mui-media-body">商品购买</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="#">
                        <img src="../../images/menu4.png">
                        <div class="mui-media-body">留言反馈</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="#">
                        <img src="../../images/menu5.png">
                        <div class="mui-media-body">视频专区</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="#">
                        <img src="../../images/menu6.png">
                        <div class="mui-media-body">联系我们</div>
                    </router-link>
                </li>
            </ul>
        </div>

    </div>
</template>

<script>
    // 引入 轮播图 组件
    import carouse from '../subComponents/carouselComponent.vue'

    export default {
        data() {
            return {
                // 轮播图列表
                carouselList: [],
            }
        },
        created() {
            // vm 实例 创建完成时
            this.getCarouselList()
        },
        methods: {
            // 获取轮播图列表
            getCarouselList() {
                this.$http.get('api/getlunbo')
                    .then(function (data) {
                        var data = data.body
                        // 判断 是否 获取成功 失败 退出
                        if (data.status !== 0) {
                            return this.$store.commit('ToastInfo', {msg: '数据获取失败'})
                        }
                        // 为 carouselList 赋值
                        this.carouselList = data.message
                    }, function () {
                        // 如果失败
                        this.$store.commit('ToastInfo', {msg: 'Server error 500', pos: 'middle'})
                    })
            }
        },
        // 组件
        components: {
            // 轮播图组件
            carouse
        }
    }
</script>

<style scoped lang="less">
    .homeContainer {
        // 图片区域
        // 九宫格 区域
        .gridView {
            ul {
                background-color: #fff;
                li {
                    border: none;
                    img {
                        width: 60px;
                        height: 60px;
                    }
                    .mui-media-body {
                        font-size: 13px;
                    }
                }
            }
        }
    }

</style>